<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>poetry 后台管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="icon" type="image/ico" href="/images/logo.png"/>

    <link rel="stylesheet" href="/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/layui/css/common.css" media="all">
    <link rel="stylesheet" href="/css/bly-icon.css" media="all">
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    <div th:replace="user/common::headerhtml"></div>
    <!--    <div th:replace="user/common::menuhtml"></div>-->
    <div class="layui-container">
        <!-- 内容主体区域 -->
        <div style="padding-top: 15px;color: #666666">
            <div class="layui-fluid">
                <div class="layui-row layui-col-space15">
                    <div class="layui-col-md12">
                        <div class="layui-card">
                            <div class="layui-card-header">修改密码</div>
                            <div class="layui-card-body" pad15="">

                                <div class="layui-form" lay-filter="">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">旧密码</label>
                                        <div class="layui-input-inline">
                                            <input type="password" id="oldPass" name="oldPass" autocomplete="off"
                                                   placeholder="请输入旧密码" class="layui-input">
                                        </div>
                                        <div class="layui-form-mid layui-word-aux"></div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">新密码</label>
                                        <div class="layui-input-inline">
                                            <input type="password" id="newPass" name="newPass" autocomplete="off"
                                                   placeholder="请输入新密码" class="layui-input">
                                        </div>
                                        <div class="layui-form-mid layui-word-aux">建议密码使用英文、数字、符号</div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">确认密码</label>
                                        <div class="layui-input-inline">
                                            <input type="password" id="okPass" name="okPass" autocomplete="off"
                                                   placeholder="请输入新密码" class="layui-input">
                                        </div>
                                        <div class="layui-form-mid layui-word-aux"></div>
                                    </div>
                                    <div class="layui-form-item">
                                        <div class="layui-input-block">
                                            <button class="layui-btn btn-update-pass" lay-submit=""
                                                    lay-filter="setmyinfo">确认修改
                                            </button>
                                        </div>
                                    </div>
                                </div>

                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div th:replace="user/common::footerhtml"></div>
</div>
<script src="/layui/layui.js" charset="utf-8"></script>
<script src="/layui/menu.js" charset="utf-8"></script>
<script type="text/javascript">
    layui.use(['element','layer'], function () {
        var el = layui.element,
            $ = layui.jquery;

        $('.btn-update-pass').on('click', function () {
            var oldPass = $('#oldPass').val();
            var newPass = $('#newPass').val();
            var okPass = $('#okPass').val();
            if (!oldPass || !newPass || !okPass) {
                layer.alert("输入框不能为空");
                return;
            }
            if (newPass.length < 6) {
                layer.msg("密码长度不能低于6位");
                return;
            }
            if (newPass != okPass) {
                layer.msg("两次密码输入不一致");
                return;
            }

            $.ajax({
                url: '../user/pass',
                type: 'post',
                dataType: 'json',
                data: {
                    oldPass:oldPass,
                    newPass:newPass
                },
                success: function (res) {
                    if (res.status != 200) {
                        layer.alert((res.msg || "修改失败！"), {icon: 5});
                        return;
                    }
                    layer.alert("修改成功！", {icon: 6});
                }
            });
        });
    })
</script>
</body>